home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / weblibev / weblibbc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-02  |  11.2 KB  |  300 lines

  1.  
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
  4. // the terms and conditions of the software license agreement.
  5.  
  6. #ifndef __WEBLIBBC_H__
  7. #define __WEBLIBBC_H__
  8.  
  9. #ifndef WEBLIB_NO_OWL
  10. #include <owl/window.h>
  11. #endif
  12. #include "weblib.h"
  13. #include "dispatbc.h"
  14.  
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // Browser classes.
  17. //
  18. // The TWeblibBrowserAPI class is a simple C++ wrapper around the API.
  19.  
  20. class TWeblibBrowserAPI
  21. {
  22.   public:
  23.     TWeblibBrowserAPI();
  24.     TWeblibBrowserAPI(WORD wOptions);
  25.     virtual ~TWeblibBrowserAPI();
  26.  
  27.     BOOL IsGood() const;
  28.  
  29.     BOOL ConnectBrowser(WORD wOptions = WL_POSTMESSAGE | WL_STARTBROWSER);
  30.     BOOL DisconnectBrowser(BOOL bExit = TRUE);
  31.  
  32.     BOOL GetWindowInfo(DWORD dwWindow,LPSTR lpszURL,int cbURL,LPSTR lpszTitle,int cbTitle) const;
  33.     DWORD ListWindows(BOOL bFirst) const;
  34.  
  35.     DWORD ActivateWindow(DWORD dwWindow) const;
  36.     BOOL CloseWindow(DWORD dwWindow) const;
  37.  
  38.     BOOL SetWindowPos(DWORD dwWindow,DWORD dwX,DWORD dwY,DWORD dwWidth,DWORD dwHeight) const;
  39.     BOOL ShowWindow(DWORD dwWindow,UINT nShow) const;
  40.  
  41.     virtual DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  42.         HWND hwndNotify,UINT nMsg) const;
  43.  
  44.     virtual DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  45.         HWND hwndNotify,UINT nMsg) const;
  46.     virtual DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  47.         HWND hwndNotify,UINT nMsg) const;
  48.  
  49.     virtual DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,LPCSTR lpszMIMEType,
  50.         HWND hwndNotify,UINT nMsg) const;
  51.     virtual DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  52.         LPCSTR lpszMIMEType,HWND hwndNotify,UINT nMsg) const;
  53.             
  54.     BOOL Cancel(DWORD dwTransaction) const;
  55.         
  56.     virtual BOOL RegisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify,UINT nMsg) const;
  57.     virtual BOOL UnregisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify) const;
  58.     
  59.     virtual BOOL RegisterURLEcho(HWND hwndNotify,UINT nMsg) const;
  60.     virtual BOOL UnregisterURLEcho(HWND hwndNotify) const;
  61.     
  62.     virtual BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions,HWND hwndNotify,UINT nMsg) const;
  63.     virtual BOOL UnregisterViewer(LPCSTR lpszMIMEType,HWND hwndNotify) const;
  64.     
  65.     virtual BOOL RegisterWindowChange(DWORD dwWindow,HWND hwndNotify,UINT nMsg) const;
  66.     virtual BOOL UnregisterWindowChange(DWORD dwWindow,HWND hwndNotify) const;
  67.     
  68.     LPCSTR ParseAnchor(LPCSTR lpszAbsoluteURL,LPCSTR lpszRelativeURL) const;
  69.     DWORD GetVersion(WORD wMajor,WORD wMinor) const;
  70.     
  71.     LPCSTR QueryURLFile(LPCSTR lpszFile) const;        // Netscape only!
  72.  
  73.     BOOL SetNotifyMethod(WORD wMethod) const;    
  74.     DWORD GetTransactionWindow(DWORD dwTransaction) const;
  75.     
  76.   protected:
  77.       HBROWSER GetBrowserHandle() const
  78.           { return m_hBrowser; }
  79.  
  80.   private:
  81.     HBROWSER m_hBrowser;
  82. };
  83.  
  84. ///////////////////////////////////////////////////////////////////////////////
  85. // If just want to use the above TWeblibBrowserAPI base class w/o OWL, then define
  86. // WEBLIB_NO_OWL in your project (for non-Borland C++ compilers and class libraries).
  87.  
  88. #ifndef WEBLIB_NO_OWL
  89.  
  90. ///////////////////////////////////////////////////////////////////////////////
  91. // The TWeblibBrowser derived class handles browser event notification automatically,
  92. // invoking the proper virtual event handler method when an event is received. To use,
  93. // derive your own class from TWeblibBrowser and override the notification handlers.
  94.  
  95. class TWeblibBrowser : public TWeblibBrowserAPI, public TWeblibDispatch
  96. {
  97.   public:
  98.       TWeblibBrowser();   
  99.       TWeblibBrowser(WORD wOptions);
  100.       virtual ~TWeblibBrowser();
  101.       
  102.       BOOL IsGood() const;
  103.       
  104.       ///////////////////////////////////////////////////////////////////////////
  105.     // New public methods intended to supplant all base class methods that take
  106.     // a notification window and message (notifications are sent to internal window).
  107.  
  108.     DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  109.         BOOL bNotify = TRUE) const;
  110.         
  111.     DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  112.         BOOL bNotify = TRUE) const;
  113.     DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  114.         BOOL bNotify = TRUE) const;
  115.  
  116.     DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,
  117.         LPCSTR lpszMIMEType,BOOL bNotify = TRUE) const;
  118.     DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  119.         LPCSTR lpszMIMEType,BOOL bNotify = TRUE) const;
  120.             
  121.     BOOL RegisterProtocol(LPCSTR lpszProtocol) const;
  122.     BOOL UnregisterProtocol(LPCSTR lpszProtocol) const;
  123.     
  124.     BOOL RegisterURLEcho() const;
  125.     BOOL UnregisterURLEcho() const;
  126.     
  127.     BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions) const;
  128.     BOOL UnregisterViewer(LPCSTR lpszMIMEType) const;
  129.     
  130.     BOOL RegisterWindowChange(DWORD dwWindow) const;
  131.     BOOL UnregisterWindowChange(DWORD dwWindow) const;
  132.     
  133.     ///////////////////////////////////////////////////////////////////////////
  134.     // Notification event handlers (override in your TWeblibBrowser-derived class).
  135.  
  136.     virtual void OnBeginProgress(DWORD dwTransaction,LPCSTR lpszProgress);
  137.     virtual void OnSetProgressRange(DWORD dwTransaction,DWORD dwMaximum);
  138.     virtual void OnMakingProgress(DWORD dwTransaction,DWORD dwProgress,LPCSTR lpszProgress);
  139.     virtual void OnEndProgress(DWORD dwTransaction);
  140.     
  141.     virtual void OnFinished(DWORD dwTransaction,DWORD dwWindow);
  142.     virtual void OnCanceled(DWORD dwTransaction);
  143.     
  144.     virtual void OnURLEcho(DWORD dwWindow,LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszReferrer);
  145.         
  146.     virtual void OnOpenURL(DWORD dwTransaction,DWORD dwWindow,DWORD dwFlags,
  147.         LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszSaveFile,LPCSTR lpszFormData);
  148.             
  149.     virtual void OnWindowChange(DWORD dwWindow,DWORD dwFlags,DWORD dwX,DWORD dwY,
  150.         DWORD dwWidth,DWORD dwHeight);
  151.         
  152.     virtual void OnQueryViewer(LPCSTR lpszURL,LPCSTR lpszMIME,LPSTR lpszFile,UINT cbFile);
  153.         
  154.     virtual void OnViewDocFile(DWORD dwWindow,LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszFile);
  155.         
  156.     ///////////////////////////////////////////////////////////////////////////
  157.     // Internal window passes notification messages to Dispatch() method.
  158.         
  159.       virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
  160.     
  161.   private:
  162.   
  163.     ///////////////////////////////////////////////////////////////////////////
  164.     // Override public base class methods that take a notification window as
  165.     // private (i.e., unavailable) since notifications are now sent to m_pWnd.
  166.     
  167.      virtual DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  168.         HWND hwndNotify,UINT nMsg) const;
  169.         
  170.     virtual DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  171.         HWND hwndNotify,UINT nMsg) const;
  172.     virtual DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  173.         HWND hwndNotify,UINT nMsg) const;
  174.  
  175.     virtual DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,LPCSTR lpszMIMEType,
  176.         HWND hwndNotify,UINT nMsg) const;
  177.     virtual DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  178.         LPCSTR lpszMIMEType,HWND hwndNotify,UINT nMsg) const;
  179.             
  180.     virtual BOOL RegisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify,UINT nMsg) const;
  181.     virtual BOOL UnregisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify) const;
  182.     
  183.     virtual BOOL RegisterURLEcho(HWND hwndNotify,UINT nMsg) const;
  184.     virtual BOOL UnregisterURLEcho(HWND hwndNotify) const;
  185.     
  186.     virtual BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions,HWND hwndNotify,UINT nMsg) const;
  187.     virtual BOOL UnregisterViewer(LPCSTR lpszMIMEType,HWND hwndNotify) const;
  188.  
  189.     virtual BOOL RegisterWindowChange(DWORD dwWindow,HWND hwndNotify,UINT nMsg) const;
  190.     virtual BOOL UnregisterWindowChange(DWORD dwWindow,HWND hwndNotify) const;
  191.  
  192.     TWindow *m_pWindow;
  193. };
  194.  
  195. #endif    // WEBLIB_NO_OWL
  196.  
  197. ///////////////////////////////////////////////////////////////////////////////
  198. // Toolbar classes.
  199. //
  200. // The TWeblibToolbarAPI class is a simple C++ wrapper around the API.
  201.  
  202. class TWeblibToolbarAPI
  203. {
  204.   public:
  205.       TWeblibToolbarAPI();
  206.       TWeblibToolbarAPI(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  207.       virtual ~TWeblibToolbarAPI();
  208.       
  209.       BOOL IsGood() const;
  210.  
  211.     virtual BOOL CreateToolbar(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  212.     BOOL DeleteToolbar();
  213.  
  214.     BOOL IsToolbarActive() const;
  215.     BOOL SetActiveToolbar() const;
  216.     
  217.     BOOL AddToolbarButton(UINT nID,int nIdx,LPCSTR lpszText,HINSTANCE hInstance,
  218.         LPCSTR lpszBitmap,LPCSTR lpszBitmapSel,LPCSTR lpszBitmapFocus,
  219.             LPCSTR lpszBitmapDisabled) const;
  220.     BOOL RemoveToolbarButton(UINT nID) const;  
  221.     
  222.     BOOL IsToolbarButtonVisible(UINT nID) const;
  223.     BOOL ShowToolbarButton(UINT nID,BOOL bShow) const;
  224.     
  225.     BOOL EnableToolbarButton(UINT nID,BOOL bEnable) const;
  226.     BOOL IsToolbarButtonEnabled(UINT nID) const;
  227.     
  228.     LPCSTR GetToolbarText(UINT nID) const;
  229.     BOOL SetToolbarText(UINT nID,LPCSTR lpszText) const;
  230.     
  231.     HFONT GetToolbarFont(WORD wType) const;
  232.     BOOL SetToolbarFont(WORD wType,HFONT hFont) const;
  233.     
  234.     COLORREF GetToolbarBkgnd() const;
  235.     BOOL SetToolbarBkgnd(COLORREF crBackground) const;
  236.  
  237.     COLORREF GetToolbarTextColor(WORD wType) const;
  238.     BOOL SetToolbarTextColor(WORD wType,COLORREF crText) const;
  239.     
  240.   protected:
  241.     HTOOLBAR GetToolbarHandle() const
  242.         { return m_hToolbar; }
  243.  
  244.   private:
  245.     HTOOLBAR m_hToolbar;
  246. };
  247.  
  248. ///////////////////////////////////////////////////////////////////////////////
  249. // If just want to use the above TWeblibToolbarAPI base class w/o OWL, then define
  250. // WEBLIB_NO_OWL in your project (for non-Borland C++ compilers and class libraries).
  251.  
  252. #ifndef WEBLIB_NO_OWL
  253.  
  254. ///////////////////////////////////////////////////////////////////////////////
  255. // The TWeblibToolbar derived class handles button click notification via a
  256. // virtual event handler method. To use, derive your own class from TWeblibToolbarAPI
  257. // and override the button click notification handler.
  258.  
  259. class TWeblibToolbar : public TWeblibToolbarAPI, public TWeblibDispatch
  260. {
  261.   public:
  262.     TWeblibToolbar();
  263.     TWeblibToolbar(LPCSTR lpszMenu);
  264.     virtual ~TWeblibToolbar();
  265.  
  266.     BOOL IsGood() const;
  267.  
  268.     ///////////////////////////////////////////////////////////////////////////
  269.     // New public methods intended to supplant all base class methods that take
  270.     // a notification window and message (notifications are now sent to m_pWnd).
  271.  
  272.     BOOL CreateToolbar(LPCSTR lpszMenu);
  273.  
  274.     ///////////////////////////////////////////////////////////////////////////
  275.     // Notification event handlers (override in your TWeblibToolbar-derived class).
  276.  
  277.     virtual void OnButtonClicked(UINT nButtonID);
  278.  
  279.     ///////////////////////////////////////////////////////////////////////////
  280.     // Internal window passes notification messages to Dispatch() method.
  281.         
  282.       virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
  283.         
  284.   private:
  285.   
  286.       ///////////////////////////////////////////////////////////////////////////
  287.     // Override public base class methods that take a notification window as 
  288.     // private (i.e., unavailable) since notifications are sent to internal window.
  289.     
  290.     virtual BOOL CreateToolbar(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  291.  
  292.     TWindow *m_pWindow;
  293. };
  294.  
  295. #endif        // WEBLIB_NO_OWL
  296.  
  297. #include "weblibbc.inl"
  298.  
  299. #endif        // __WEBLIBVC_H__
  300.